package com.jhoncy.myproject.common.dto;

import lombok.Getter;
import lombok.Setter;

/**
 * Created by zhuangqi on 2017/2/24.
 */
@Getter
@Setter
public class RestResponse<T> {

    private static final Integer RESPONSE_CODE_FAILSE = 100;
    private static final Integer RESPONSE_CODE_SUCCESE = 200;
    private static final Integer RESPONSE_CODE_ERRO = 500;

    private Integer code;
    private String message;
    private T data;

    public RestResponse() {
        super();
        this.code = RESPONSE_CODE_SUCCESE;
        this.message = null;
        this.data = null;
    }


    /**
     * 系统错误
     * @param message
     * @return
     */
    public RestResponse setErroResponse(String message){
        this.setMessage(message);
        this.setCode(RESPONSE_CODE_FAILSE);
        return this;
    }

    /**
     * 业务失败
     * @param message
     * @return
     */
    public RestResponse setFailseResponse(String message){
        this.setMessage(message);
        this.setCode(RESPONSE_CODE_FAILSE);
        return this;
    }

}
